package com.liujit.bms.app.controller;

import com.liujit.bms.app.domain.query.BlogArticleQuery;
import com.liujit.bms.app.domain.query.BlogTimeArchiveQuery;
import com.liujit.bms.app.domain.result.BlogArticleResult;
import com.liujit.bms.app.domain.result.BlogTimeArchiveResult;
import com.liujit.bms.app.service.BlogArticleService;
import com.liujit.common.domain.result.PageBean;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description 博客文章管理接口
 * @Author liujun
 * @Date 2021-07-13 11:13:55
 */
@RequiredArgsConstructor
@Api(tags = "博客文章管理接口")
@RestController
@RequestMapping("/blog/article")
public class BlogArticleController {

    private final BlogArticleService blogArticleService;

    @ApiOperation(value = "分页查询", notes = "根据博客文章分页查询条件，分页查询博客文章列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "query", value = "博客文章分页查询条件", dataType = "BlogArticleQuery", dataTypeClass = BlogArticleQuery.class, paramType = "query") })
    @GetMapping("/getPage")
    public PageBean<BlogArticleResult> getPage(BlogArticleQuery query) {
        return blogArticleService.getPage(query);
    }

    @ApiOperation(value = "查询", notes = "根据博客文章id，查询博客文章")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "博客文章id", dataType = "Long", dataTypeClass = Long.class, paramType = "query") })
    @GetMapping("/get")
    public BlogArticleResult get(Long id) {
        return blogArticleService.get(id);
    }

    @ApiOperation(value = "查询时间归档", notes = "根据博客文章时间归档查询条件，查询时间归档列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "query", value = "博客文章时间归档查询条件", dataType = "BlogArticleQuery", dataTypeClass = BlogArticleQuery.class, paramType = "query") })
    @GetMapping("/getTimeArchive")
    public List<BlogTimeArchiveResult> getTimeArchive(BlogTimeArchiveQuery query) {
        return blogArticleService.getTimeArchive(query);
    }
}
